package top.whk0710.other;

import java.util.Scanner;


public class Demo {

	public static void main(String[] args) {
		
		 Scanner sc = new Scanner(System.in);
	     String input = sc.nextLine();
	     String[] list = input.split(" ");
	 
	     String first = list[0];
	     String end = list[list.length-1];
	     
	     //System.out.println(end.toCharArray()[0]);
	     
	     int count=0;
	     for(int i=0;i<first.length();i++){
	    	 if(first.charAt(i) == end.toCharArray()[0]){
	    		 count++;
	    	 }
	     }
	     
	     System.out.println(count);
	    
	     
	     sc.close();
	}
}
